if (typeof (mediator) == 'undefined')
	mediator = {};

if (typeof (mediator.space) == 'undefined')
	mediator.space = {};


mediator.space.createViewMediator = function(pid) {
	
	//个人信息
	var person = model.person.factory.createByPersonId(pid);
	mediator.personInfoWidget.createViewMediator(pid);
	
	var teachingListApp = mediator.teachingList.createViewMediator({pid : pid});
	var studyingListApp = mediator.studyingList.createViewMediator({pid : pid});
	var countViewApp = mediator.teachingsStudiesCount.createViewMediator(teachingListApp.teachings().length , studyingListApp.studies().length);
	
	
	var teachingViewNode = $('#teachesView')[0];
	applyBindings(teachingListApp, teachingViewNode);

	var studyViewNode = $('#studiesView')[0];
	applyBindings(studyingListApp, studyViewNode);
	
	//所学的数目和所教的数目
	
	var countViewNode = $('#counts')[0];
	applyBindings(countViewApp, countViewNode);
};


function initPersonInfoView() {
	//个人信息
	$('#personInfo').attr('data-bind', 'with: person');
	$("#realName").attr('data-bind', "visible : realName");
	$("#workUnit").attr('data-bind', "visible : workUnit");
	$("#telephone").attr('data-bind', "visible : telephone");
	$("#email").attr('data-bind', "visible : email ");
	$("#qq").attr('data-bind', "visible : qq");
	$("#location").attr('data-bind', "visible : location ");
	$("#job").attr('data-bind', "visible : job ");

	$("#headPortrait").attr("data-bind", "attr:{src:headPortrait}");
	$('#signature').attr('data-bind', 'text:signature');
	$('#showName').attr('data-bind', 'text:showName');
	$('#countTeaches').attr('data-bind', 'text: $parent.teaches().length');
	$('#countStudies').attr('data-bind', 'text: $parent.studies().length');

	$('#realName > sapn').attr('data-bind', 'text : realName');
	$("#location > span").attr('data-bind', 'text : location');
	$("#workUnit > span").attr('data-bind', 'text : workUnit');
	$("#telephone > span").attr('data-bind', 'text : telephone');
	$("#email > span").attr('data-bind', 'text : email');
	$("#qq > span").attr('data-bind', 'text : qq');
	$("#job > span").attr('data-bind', 'text : job');

	
};

